import Vue from 'vue';
import Router from 'vue-router';
import { Util, AuthGuard } from '@/utils';
import { Environment } from '@/environments/environment';
import {userrouter} from "@/userrouter";

Vue.use(Router);

let routes =  [
        {
            path: '/demo_indexview/:demo_indexview?',
            name: 'demo_indexview',
            beforeEnter: (to: any, from: any, next: any) => {
                const routerParamsName = 'demo_indexview';
                const params: any = {};
                if (to.params && to.params[routerParamsName]) {
                    Object.assign(params, Util.formatMatrixParse(to.params[routerParamsName]));
                }
                const url: string = 'demoapp/app/demoapp/getappdata';
                const auth: Promise<any> = AuthGuard.getInstance().authGuard(url, params, router);
                auth.then(() => {
                    next();
                }).catch(() => {
                    next();
                });
            },
            meta: {
                caption: '首页',
                viewType: 'APPINDEX',
                requireAuth: true,
            },
            component: () => import('@pages/'+Environment.defaultIndexViewPath),
            children: [
                {
                    path: 'rtsys_userroledataseditview/:rtsys_userroledataseditview?',
                    name: 'rtsys_userroledataseditview',
                    meta: {
                        caption: '用户角色数据能力',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-datas-edit-view/user-role-datas-edit-view'),
                },
                {
                    path: 'rtsys_orgsectorpickupgridview/:rtsys_orgsectorpickupgridview?',
                    name: 'rtsys_orgsectorpickupgridview',
                    meta: {
                        caption: '组织部门',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/org-sector-pickup-grid-view/org-sector-pickup-grid-view'),
                },
                {
                    path: 'rtsys_userroledetaileditview/:rtsys_userroledetaileditview?',
                    name: 'rtsys_userroledetaileditview',
                    meta: {
                        caption: '用户角色成员',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-detail-edit-view/user-role-detail-edit-view'),
                },
                {
                    path: 'rtsys_unirespickupgridview/:rtsys_unirespickupgridview?',
                    name: 'rtsys_unirespickupgridview',
                    meta: {
                        caption: '统一资源',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/uni-res-pickup-grid-view/uni-res-pickup-grid-view'),
                },
                {
                    path: 'rtsys_userrolereseditview/:rtsys_userrolereseditview?',
                    name: 'rtsys_userrolereseditview',
                    meta: {
                        caption: '用户角色资源能力',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-res-edit-view/user-role-res-edit-view'),
                },
                {
                    path: 'rtsys_querymodelpickupgridview/:rtsys_querymodelpickupgridview?',
                    name: 'rtsys_querymodelpickupgridview',
                    meta: {
                        caption: '实体查询模型',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/query-model-pickup-grid-view/query-model-pickup-grid-view'),
                },
                {
                    path: 'rtsys_orgsectorgridview/:rtsys_orgsectorgridview?',
                    name: 'rtsys_orgsectorgridview',
                    meta: {
                        caption: '组织部门',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/org-sector-grid-view/org-sector-grid-view'),
                },
                {
                    path: 'rtsys_userroledefieldseditview/:rtsys_userroledefieldseditview?',
                    name: 'rtsys_userroledefieldseditview',
                    meta: {
                        caption: '用户角色相关实体属性访问控制',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-defields-edit-view/user-role-defields-edit-view'),
                },
                {
                    path: 'rtsys_loginaccountgridview/:rtsys_loginaccountgridview?',
                    name: 'rtsys_loginaccountgridview',
                    meta: {
                        caption: '登录帐户',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/login-account-grid-view/login-account-grid-view'),
                },
                {
                    path: 'rtsys_userroledataactioneditview/:rtsys_userroledataactioneditview?',
                    name: 'rtsys_userroledataactioneditview',
                    meta: {
                        caption: '用户角色数据操作',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-data-action-edit-view/user-role-data-action-edit-view'),
                },
                {
                    path: 'rtsys_userroledataeditview3/:rtsys_userroledataeditview3?',
                    name: 'rtsys_userroledataeditview3',
                    meta: {
                        caption: '数据对象能力',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-data-edit-view3/user-role-data-edit-view3'),
                },
                {
                    path: 'rtsys_orgsectoreditview/:rtsys_orgsectoreditview?',
                    name: 'rtsys_orgsectoreditview',
                    meta: {
                        caption: '组织部门',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/org-sector-edit-view/org-sector-edit-view'),
                },
                {
                    path: 'rtsys_userroledataactiongridview/:rtsys_userroledataactiongridview?',
                    name: 'rtsys_userroledataactiongridview',
                    meta: {
                        caption: '用户角色数据操作',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-data-action-grid-view/user-role-data-action-grid-view'),
                },
                {
                    path: 'rtsys_dataentitygridview/:rtsys_dataentitygridview?',
                    name: 'rtsys_dataentitygridview',
                    meta: {
                        caption: '实体',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/data-entity-grid-view/data-entity-grid-view'),
                },
                {
                    path: 'rtsys_loginaccounteditview/:rtsys_loginaccounteditview?',
                    name: 'rtsys_loginaccounteditview',
                    meta: {
                        caption: '登录帐户',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/login-account-edit-view/login-account-edit-view'),
                },
                {
                    path: 'rtsys_userrolegridview/:rtsys_userrolegridview?',
                    name: 'rtsys_userrolegridview',
                    meta: {
                        caption: '用户角色',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-grid-view/user-role-grid-view'),
                },
                {
                    path: 'rtsys_userroledatagridview/:rtsys_userroledatagridview?',
                    name: 'rtsys_userroledatagridview',
                    meta: {
                        caption: '数据对象能力',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-data-grid-view/user-role-data-grid-view'),
                },
                {
                    path: 'rtsys_userroledatadetaileditview/:rtsys_userroledatadetaileditview?',
                    name: 'rtsys_userroledatadetaileditview',
                    meta: {
                        caption: '数据对象能力明细',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-data-detail-edit-view/user-role-data-detail-edit-view'),
                },
                {
                    path: 'rtsys_userroledatapickupgridview/:rtsys_userroledatapickupgridview?',
                    name: 'rtsys_userroledatapickupgridview',
                    meta: {
                        caption: '数据对象能力',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-data-pickup-grid-view/user-role-data-pickup-grid-view'),
                },
                {
                    path: 'rtsys_dataentitypickupgridview/:rtsys_dataentitypickupgridview?',
                    name: 'rtsys_dataentitypickupgridview',
                    meta: {
                        caption: '实体',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/data-entity-pickup-grid-view/data-entity-pickup-grid-view'),
                },
                {
                    path: 'rtsys_usergroupdetaileditview/:rtsys_usergroupdetaileditview?',
                    name: 'rtsys_usergroupdetaileditview',
                    meta: {
                        caption: '用户组成员',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-group-detail-edit-view/user-group-detail-edit-view'),
                },
                {
                    path: 'rtsys_orgsecusertypepickupgridview/:rtsys_orgsecusertypepickupgridview?',
                    name: 'rtsys_orgsecusertypepickupgridview',
                    meta: {
                        caption: '部门人员关系类型',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/org-sec-user-type-pickup-grid-view/org-sec-user-type-pickup-grid-view'),
                },
                {
                    path: 'rtsys_orgsectorcurorgpickupgridview/:rtsys_orgsectorcurorgpickupgridview?',
                    name: 'rtsys_orgsectorcurorgpickupgridview',
                    meta: {
                        caption: '组织部门',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/org-sector-cur-org-pickup-grid-view/org-sector-cur-org-pickup-grid-view'),
                },
                {
                    path: 'rtsys_userroledefieldsgridview/:rtsys_userroledefieldsgridview?',
                    name: 'rtsys_userroledefieldsgridview',
                    meta: {
                        caption: '用户角色相关实体属性访问控制',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-defields-grid-view/user-role-defields-grid-view'),
                },
                {
                    path: 'rtsys_orguserlevelpickupgridview/:rtsys_orguserlevelpickupgridview?',
                    name: 'rtsys_orguserlevelpickupgridview',
                    meta: {
                        caption: '组织人员级别',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/org-user-level-pickup-grid-view/org-user-level-pickup-grid-view'),
                },
                {
                    path: 'rtsys_wfusergroupdetailgridview/:rtsys_wfusergroupdetailgridview?',
                    name: 'rtsys_wfusergroupdetailgridview',
                    meta: {
                        caption: '工作流用户组成员',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/wfuser-group-detail-grid-view/wfuser-group-detail-grid-view'),
                },
                {
                    path: 'rtsys_wfusergroupdetaileditview/:rtsys_wfusergroupdetaileditview?',
                    name: 'rtsys_wfusergroupdetaileditview',
                    meta: {
                        caption: '工作流用户组成员',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/wfuser-group-detail-edit-view/wfuser-group-detail-edit-view'),
                },
                {
                    path: 'demo_appindexview/:demo_appindexview?',
                    name: 'demo_appindexview',
                    meta: {
                        caption: '',
                        requireAuth: true,
                    },
                    component: () => import('@pages/demo/app-index-view/app-index-view'),
                },
                {
                    path: 'common_usergroupeditview3/:common_usergroupeditview3?',
                    name: 'common_usergroupeditview3',
                    meta: {
                        caption: '用户组',
                        requireAuth: true,
                    },
                    component: () => import('@pages/common/user-group-edit-view3/user-group-edit-view3'),
                },
                {
                    path: 'rtsys_usergrouppickupgridview/:rtsys_usergrouppickupgridview?',
                    name: 'rtsys_usergrouppickupgridview',
                    meta: {
                        caption: '用户组',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-group-pickup-grid-view/user-group-pickup-grid-view'),
                },
                {
                    path: 'rtsys_userroleresgridview/:rtsys_userroleresgridview?',
                    name: 'rtsys_userroleresgridview',
                    meta: {
                        caption: '用户角色资源能力',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-res-grid-view/user-role-res-grid-view'),
                },
                {
                    path: 'rtsys_userroledatasgridview/:rtsys_userroledatasgridview?',
                    name: 'rtsys_userroledatasgridview',
                    meta: {
                        caption: '用户角色数据能力',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-datas-grid-view/user-role-datas-grid-view'),
                },
                {
                    path: 'rtsys_unireseditview/:rtsys_unireseditview?',
                    name: 'rtsys_unireseditview',
                    meta: {
                        caption: '统一资源',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/uni-res-edit-view/uni-res-edit-view'),
                },
                {
                    path: 'rtsys_orgusergridview/:rtsys_orgusergridview?',
                    name: 'rtsys_orgusergridview',
                    meta: {
                        caption: '组织人员',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/org-user-grid-view/org-user-grid-view'),
                },
                {
                    path: 'rtsys_usergroupgridview/:rtsys_usergroupgridview?',
                    name: 'rtsys_usergroupgridview',
                    meta: {
                        caption: '用户组',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-group-grid-view/user-group-grid-view'),
                },
                {
                    path: 'demo_userpickupgridview/:demo_userpickupgridview?',
                    name: 'demo_userpickupgridview',
                    meta: {
                        caption: '用户',
                        requireAuth: true,
                    },
                    component: () => import('@pages/demo/user-pickup-grid-view/user-pickup-grid-view'),
                },
                {
                    path: 'rtsys_usereditview/:rtsys_usereditview?',
                    name: 'rtsys_usereditview',
                    meta: {
                        caption: '用户',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-edit-view/user-edit-view'),
                },
                {
                    path: 'rtsys_userrolepickupgridview/:rtsys_userrolepickupgridview?',
                    name: 'rtsys_userrolepickupgridview',
                    meta: {
                        caption: '用户角色',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-pickup-grid-view/user-role-pickup-grid-view'),
                },
                {
                    path: 'rtsys_userroledatadetailgridview/:rtsys_userroledatadetailgridview?',
                    name: 'rtsys_userroledatadetailgridview',
                    meta: {
                        caption: '数据对象能力明细',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-data-detail-grid-view/user-role-data-detail-grid-view'),
                },
                {
                    path: 'rtsys_userroledetailgridview/:rtsys_userroledetailgridview?',
                    name: 'rtsys_userroledetailgridview',
                    meta: {
                        caption: '用户角色成员',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-detail-grid-view/user-role-detail-grid-view'),
                },
                {
                    path: 'rtsys_usergroupdetailgridview/:rtsys_usergroupdetailgridview?',
                    name: 'rtsys_usergroupdetailgridview',
                    meta: {
                        caption: '用户组成员',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-group-detail-grid-view/user-group-detail-grid-view'),
                },
                {
                    path: 'rtsys_userobjectpickupgridview/:rtsys_userobjectpickupgridview?',
                    name: 'rtsys_userobjectpickupgridview',
                    meta: {
                        caption: '用户对象',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-object-pickup-grid-view/user-object-pickup-grid-view'),
                },
                {
                    path: 'rtsys_userroleeditview3/:rtsys_userroleeditview3?',
                    name: 'rtsys_userroleeditview3',
                    meta: {
                        caption: '用户角色',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/user-role-edit-view3/user-role-edit-view3'),
                },
                {
                    path: 'rtsys_wfusergroupeditview3/:rtsys_wfusergroupeditview3?',
                    name: 'rtsys_wfusergroupeditview3',
                    meta: {
                        caption: '工作流用户组',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/wfuser-group-edit-view3/wfuser-group-edit-view3'),
                },
                {
                    path: 'rtsys_orgpickupgridview/:rtsys_orgpickupgridview?',
                    name: 'rtsys_orgpickupgridview',
                    meta: {
                        caption: '组织机构',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/org-pickup-grid-view/org-pickup-grid-view'),
                },
                {
                    path: 'rtsys_wfusergroupgridview/:rtsys_wfusergroupgridview?',
                    name: 'rtsys_wfusergroupgridview',
                    meta: {
                        caption: '工作流用户组',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/wfuser-group-grid-view/wfuser-group-grid-view'),
                },
                {
                    path: 'rtsys_orggridview/:rtsys_orggridview?',
                    name: 'rtsys_orggridview',
                    meta: {
                        caption: '组织机构',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/org-grid-view/org-grid-view'),
                },
                {
                    path: 'rtsys_orgusereditview/:rtsys_orgusereditview?',
                    name: 'rtsys_orgusereditview',
                    meta: {
                        caption: '组织人员',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/org-user-edit-view/org-user-edit-view'),
                },
                {
                    path: 'rtsys_orgeditview/:rtsys_orgeditview?',
                    name: 'rtsys_orgeditview',
                    meta: {
                        caption: '组织机构',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/org-edit-view/org-edit-view'),
                },
                {
                    path: 'rtsys_dataentityeditview/:rtsys_dataentityeditview?',
                    name: 'rtsys_dataentityeditview',
                    meta: {
                        caption: '实体',
                        requireAuth: true,
                    },
                    component: () => import('@pages/rtsys/data-entity-edit-view/data-entity-edit-view'),
                },
            ]
        },
        {
            path: '/login/:login?',
            name: 'login',
            meta: {
                caption: '登录',
                viewType: 'login',
                requireAuth: false,
                ignoreAddPage: true,
            },
            beforeEnter: (to: any, from: any, next: any) => {
                router.app.$store.commit('resetRootStateData');
                next();
            },
            component: () => import('@components/'+Environment.loginViewPath),
        },
        {
            path: '*',
            redirect: 'demo_indexview'
        },
    ];

const router = new Router({
    routes:[...userrouter, ...routes]
});

export default router;
